@echo off
chcp 65001
set oldPath=%cd%

@REM 存储文件位置
for /f "tokens=2 delims=''" %%i in ('findstr "testRootPath" ./vue.config.js') do set loadPath=%%i
if "%loadPath%"=="__TEST_ROOT_PATH__" (
    echo 文件存放路径设置不正确
    exit) 

@REM 获取用户名
for /f "tokens=2" %%i in ('findstr "user" %~dp0\ips.txt') do set username=%%i
@REM 获取密码
for /f "tokens=2" %%i in ('findstr "pwd" %~dp0\ips.txt') do set password=%%i
@REM 获取ip地址
for /f "tokens=2" %%i in ('findstr "ip" %~dp0\ips.txt') do set ip=%%i
@REM 上传文件路径

cd %1

tar -cvf %oldPath%\upload.tar *

cd %oldPath%

pscp -l %username% -pw %password% %oldPath%\upload.tar %ip%:%loadPath%/

del %oldPath%\upload.tar

echo cd %loadPath% >> script.txt
echo tar -xvf upload.tar >> script.txt
echo rm -rf %loadPath%/upload.tar >> script.txt

putty -ssh %username%@%ip% -pw %password% -m %oldPath%\script.txt

del %oldPath%\script.txt
